package com.wzy.optional;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

public class OptionalDemo
{

	public static void main(String[] args)
	{
		Optional<Object> objectOne = Optional.empty();

		Optional<String> objectTwo = Optional.of("hello");

		String s = objectTwo.orElse("备用方案");

		System.out.println(s);

		//2非空判断demo
		List<String> strList = new ArrayList<>();

		Optional.ofNullable(strList)
				.map(List::stream)
				.orElseGet(Stream::empty)
				.forEach(System.out::println);

		List<Integer> aaa = null;

		aaa.stream().peek(System.out::println);
	}
}
